<?php

	require_once 'config.inc';
	require_once '_common.inc';
	require_once '_merchant.inc';
	require_once '_db.inc';
	require_once '_ui.inc';

	

/*********************************************************
set the correct time zone to eliminate warnings in debug
date_default_timezone_set('America/New_York');

$script_tz = date_default_timezone_get();

if (strcmp($script_tz, ini_get('date.timezone'))){
    echo 'Script timezone differs from ini-set timezone.';
}
*********************************************************/


	$usss_str = $_POST["usss"];

	$usss = explode(":",$usss_str);
	$us = $usss[0];
	$ss = str_split($usss[1]);

?>
<HTML>

<HEAD>
	<title>Provide ID strings with respect to Merchant's Selector String</title>
</HEAD>
<BODY>
<?php
ui_print_header('Customer - Provide ID Strings');

	echo "<PRE>";
	echo "The merchant has generated the following selector string:<BR><BR>";
	echo implode($ss) . "<BR><BR>";


	echo "Retrieving ID strings...<BR><BR>";
	
/*********************************************************
connect to db
*********************************************************/
$conn = db_connect(CUSTOMER_DB_USER, CUSTOMER_DB_PASSWORD);

/*********************************************************
get available mo batches
*********************************************************/


for($i = 0; $i < sizeof($ss); $i++){

switch ($ss[$i]){
	case "0":
		$sql = "select l_id_string as id from mo_idstrings_customer where
			uniqueness_string = '" . $us . "' and idstring_n = " . ($i+1);
		break;
	case "1";
		$sql = "select r_id_string as id from mo_idstrings_customer where
			uniqueness_string = '" . $us . "' and idstring_n = " . ($i+1);
		break;
}

$qr = db_do_query($conn, $sql);
$id_str[$i] = $qr[0][ID];
}

/*********************************************************
close db connection
*********************************************************/
oci_close($conn);	

echo "ID Strings Retrieved!"

	
// Then Send
	
	?>
		<FORM action="./4R_4_MerchantValidateIDStrings.php" method="post">
		<?php  echo '<input type="hidden" name="ids" size="10" value="' . $us .":" . implode(":",$id_str) . '"/>';?>
		<input type="submit" value="Send ID Strings to Merchant" />
 </FORM>
 </PRE>
 <?php ui_print_footer(date('Y-m-d H:i:s')); ?>
</BODY>
</HTML>	
	
